﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WF = CPPEI.WorkflowCore;

namespace Demo.UserControls
{
    public partial class WorkflowHistoryViewer : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Guid instanceId = new Guid(Request.QueryString["wf:instance"]);
            WF.Instance instance = WF.Engine.Get(instanceId);
            if (instance != null)
            {
                this._ctlList.DataSource = WF.Engine.ActionRecordStorage.FindList(instanceId, 0, 999).Items;
                this._ctlList.DataBind();
            }
        }

        public string ResolveText(object paramObj)
        {
            WF.ActionRecord record = paramObj as WF.ActionRecord;

            if(record.UndertakerType == WF.UndertakerType.Self)
            {
                return string.Format("{0}-[亲办]{1}-{2}-{3}", record.Time, record.Actor.Name, record.ActionType, record.Action);
            }
            else
            {
                return string.Format("{0}-[代办]{1}-{2}-{3}", record.Time, record.Actor.Name, record.ActionType, record.Action);
            }
        }
    }
}